#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

const int maxn = 105;

struct Building {
  int id;
  double x, y, w, d, h;
  bool operator<(const Building& rhs) const {
    return x < rhs.x || (x == rhs.x && y < rhs.y);  // 重载<运算符
  }
} b[maxn];

int n;
double x[2 * maxn];

bool solve(int i, double mi) {
  if (!(b[i].x <= mi && b[i].x + b[i].w >= mi))
    return false;  // 该中点不在建筑物b[i]范围内时返回false
  for (int k = 0; k < n; k++) {
    if (b[k].y < b[i].y && b[k].h >= b[i].h && b[k].x <= mi &&
        b[k].x + b[k].w >= mi)
      return false;
    // 若该建筑物前面有建筑物并且高度大于等于该建筑物时，返回false
  }
  return true;
}

int main() {
  int kase = 0;
  while (cin >> n, n) {
    memset(x, 0, sizeof(x));
    for (int i = 0; i < n; i++) {
      cin >> b[i].x >> b[i].y >> b[i].w >> b[i].d >> b[i].h;
      b[i].id = i + 1;
      x[2 * i] = b[i].x;
      x[2 * i + 1] = b[i].x + b[i].w;
    }
    sort(b, b + n);  // 以重载方法进行排序
    sort(x, x + 2 * n);
    int m = unique(x, x + 2 * n) - x;  // 得到不重复的x坐标个数
    if (kase++) cout << endl;
    cout << "For map #" << kase
         << ", the visible buildings are numbered as follows:" << endl
         << b[0].id;
    for (int i = 1; i < n; i++) {
      bool vis = false;
      for (int j = 0; j < m; j++) {
        if (solve(i, (x[j] + x[j + 1]) / 2)) {
          vis = true;
          break;
        }
      }
      if (vis == true) cout << " " << b[i].id;
    }
    cout << endl;
  }
  return 0;
}